package com.aiyige.page.my.customer.model;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import java.util.List;

/**
 * Created by xiachao on 2018/3/27.
 */

public class CustomerScreenFatherEntity implements Parcelable {

    String id;
    String name;
    boolean selected;
    String subject = "";
    List<CustomerScreenChildEntity> list;

    public CustomerScreenFatherEntity(){

    }

    private CustomerScreenFatherEntity(Builder builder) {
        setId(builder.id);
        setName(builder.name);
        setSelected(builder.selected);
        setSubject(builder.subject);
        setList(builder.list);
    }

    protected CustomerScreenFatherEntity(Parcel in) {
        id = in.readString();
        name = in.readString();
        selected = in.readByte() != 0;
        subject = in.readString();
        list = in.createTypedArrayList(CustomerScreenChildEntity.CREATOR);
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(id);
        dest.writeString(name);
        dest.writeByte((byte) (selected ? 1 : 0));
        dest.writeString(subject);
        dest.writeTypedList(list);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<CustomerScreenFatherEntity> CREATOR = new Creator<CustomerScreenFatherEntity>() {
        @Override
        public CustomerScreenFatherEntity createFromParcel(Parcel in) {
            return new CustomerScreenFatherEntity(in);
        }

        @Override
        public CustomerScreenFatherEntity[] newArray(int size) {
            return new CustomerScreenFatherEntity[size];
        }
    };

    public static Builder newBuilder() {
        return new Builder();
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public List<CustomerScreenChildEntity> getList() {
        return list;
    }

    public void setList(List<CustomerScreenChildEntity> list) {
        this.list = list;
    }

    public static final class Builder {
        private String id;
        private String name;
        private boolean selected;
        private String subject;
        private List<CustomerScreenChildEntity> list;

        private Builder() {
        }

        public Builder id(String val) {
            id = val;
            return this;
        }

        public Builder name(String val) {
            name = val;
            return this;
        }

        public Builder selected(boolean val) {
            selected = val;
            return this;
        }

        public Builder subject(String val) {
            subject = val;
            return this;
        }

        public Builder list(List<CustomerScreenChildEntity> val) {
            list = val;
            return this;
        }

        public CustomerScreenFatherEntity build() {
            return new CustomerScreenFatherEntity(this);
        }
    }
}
